#ifndef __VIDEO__H__
#define __VIDEO__H__

#include <stdint.h>
#include <sys/time.h>

#ifdef __cplusplus
extern "C" {
#endif

#define DEVICE_NAME_SIZE		128

struct camera_buf
{
	void *start;
	uint32_t length;
	uint32_t id;
	void *arg;
};

struct camera_class
{
	char dev_name[DEVICE_NAME_SIZE];
	uint32_t width;
	uint32_t height;
	uint32_t pixel_format;

	int fd;
	int channel;

	uint32_t n_buf;
	uint32_t living;
	uint32_t active_buf_index;

	struct camera_buf *buf;

	int buf_index_lock;

	void (*release)(struct camera_class **);
	int (*new_channel)(struct camera_class *, int);
	int (*video_open)(struct camera_class *);
	int (*show_cap)(struct camera_class *);
	int (*enum_fmt)(struct camera_class *);
	int (*set_fmt)(struct camera_class *);
	uint32_t (*req_buf)(struct camera_class *, uint32_t);
	int (*alloc_buf)(struct camera_class *);
	int (*mmap_buf)(struct camera_class *);
	int (*init_buf)(struct camera_class *);
	int (*push_buf)(struct camera_class *);
	int (*pop_buf)(struct camera_class *);
	int (*start_stream)(struct camera_class *);
	int (*stop_stream)(struct camera_class *);
	int (*is_living)(struct camera_class *);
	int (*ignore_frame)(struct camera_class *, int, int);
	int (*get_frame)(struct camera_class *, int);
	int (*get_bufdup)(struct camera_class *, struct camera_buf **);
	int (*free_bufdup)(struct camera_class *, struct camera_buf **);
};

extern struct camera_class *video_init(char *, int, uint32_t, uint32_t, uint32_t);

#ifdef __cplusplus
}
#endif

#endif